package demo.edu.cacuculate;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class CaculateActivity extends Activity {
	EditText edtSOA, edtSOB;
	TextView tvKETQUA;
	Button btnTONG, btnHIEU;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_caculate);
		init();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.caculate, menu);
		return true;
	}

//	public void OnClick_TinhTong(View v) {
//		int a = Integer.parseInt(edtSOA.getText().toString());
//		int b = Integer.parseInt(edtSOB.getText().toString());
//		tvKETQUA.setText("Tổng hai số là:" + (a + b));
//	}
//
//	public void OnClick_TinhHieu(View v) {
//		int a = Integer.parseInt(edtSOA.getText().toString());
//		int b = Integer.parseInt(edtSOB.getText().toString());
//		tvKETQUA.setText("Hieu 2 so " + (a - b));
//	}

	public void init() {
		edtSOA = (EditText) findViewById(R.id.edtSoa);
		edtSOB = (EditText) findViewById(R.id.edtSob);
		btnTONG = (Button) findViewById(R.id.btTinhTong);
		btnHIEU = (Button) findViewById(R.id.btTinhHieu);
		tvKETQUA = (TextView) findViewById(R.id.tvKetQua);
		//Tinh hieu 2 so
		btnHIEU.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				int a = Integer.parseInt(edtSOA.getText().toString());
				int b = Integer.parseInt(edtSOB.getText().toString());
				tvKETQUA.setText("Hieu 2 so: "+(a-b));
			}
		});
		//Tinh tong 2 so 
		btnTONG.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				int a = Integer.parseInt(edtSOA.getText().toString());
				int b = Integer.parseInt(edtSOB.getText().toString());
				tvKETQUA.setText("Tong hai so: "+(a+b));
				
			}
		});

	}

}
